package com.wbt.huawei.c20220722;

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            int num = in.nextInt();
            int[] arr = new int[num];
            for (int i = 0; i< num;i++){
                arr[i] = in.nextInt();
            }

            for (int i = 0;i<num -1; i++){
                for (int j = i+1; j<num; j++){
                    if(arr[i] % 2 != arr[j] % 2){
                        continue;
                    }
                    if(arr[i] % 2 == 0){ // 偶数
                        if(arr[i] < arr[j]){
                            int temp = arr[i];
                            arr[i] = arr[j];
                            arr[j] = temp;
                        }
                    }else {
                        if(arr[i] > arr[j]){
                            int temp = arr[i];
                            arr[i] = arr[j];
                            arr[j] = temp;
                        }
                    }
                }
            }
            /*for (int k = 0;k<num;k++){
                System.out.print(arr[k] + " ");
            }*/
            Arrays.stream(arr).peek(v -> System.out.print(v + " ")).toArray();
        }
    }
}
